class KGameCenter {
    private var playerManager = KPlayerManager.sharedInstance()
    private var board = KGobangBoard()
    private var ruleCenter = KRuleCenter()

    companion object{
        val INSTANCE = KGameCenter()
    }

    fun start(){
        while (true) {
            val location = playerManager.getCurrentPlayer().chooseLocation().also {  }
            val result = board.placeChess(location, playerManager.getCurrentPlayer())
            if (!result){
                continue
            }
            //判断
            if(ruleCenter.isWin(location)){
                println("游戏结束 ${playerManager.getCurrentPlayer().name} 赢了")
                break
            }

            if (ruleCenter.isFull()){
                println("平局")
                break
            }
            playerManager.changePlayer()
        }
    }
}

fun main() {
    KGameCenter.INSTANCE.start()
}